package org.hoyi.servmotions;

import java.io.File;

import org.apache.commons.io.monitor.FileAlterationListenerAdaptor;
import org.hoyi.DB.ctrl.Console;

public class motionFileListener extends FileAlterationListenerAdaptor {
	
	private Runnable Restart_Runnable;
	
	public  motionFileListener(Runnable _Restart_Runnable) {
		Restart_Runnable = _Restart_Runnable;
	}
	
	public void Restart() {
		if(Restart_Runnable != null) {
			new Thread(Restart_Runnable).start();
		}
	}

	@Override
	public void onFileChange(File file) {
		Console.Info("onFileChange:" + file.getAbsolutePath());
		Restart();
	}
	
	@Override
	public void onFileCreate(File file) {
		Console.Info("onFileCreate:" + file.getAbsolutePath());
		Restart();
	}
	
	@Override
	public void onFileDelete(File file) {
		Console.Info("onFileDelete:" + file.getAbsolutePath());
		Restart();
	}
	
}
